package com.wut.core.common.vo;

import cn.hutool.http.HttpStatus;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("服务基础返回数据格式")
public class BaseResponse<T> implements Serializable {

    @ApiModelProperty(value = "状态码", example = "200")
    private int code;
    @ApiModelProperty(value = "响应信息", example = "成功")
    private String message;
    @ApiModelProperty(value = "响应数据", example = "")
    private T data;
    @ApiModelProperty(value = "请求ID", example = "")
    private String requestId;

    public BaseResponse(T data) {
        this.data = data;
    }

    public BaseResponse(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> BaseResponse<T> SUCCESS() {
        return new BaseResponse<>();
    }

    public static <T> BaseResponse<T> SUCCESS(T data) {
        return new BaseResponse<>(data);
    }

    public static <T> BaseResponse<T> SUCCESS(String message, T data) {
        return new BaseResponse<>(HttpStatus.HTTP_OK, message, data);
    }

    private static final long serialVersionUID = 1L;
}